<?php
/**
 * interface of the dao adaptor
 * that provides methods to query the db
 * and fetch results
 * @author bbqq <toughgamer@gmail.com>
 * @package com.blib.data
 * @copyright bbqq qstufie.com
 * @throws Dao_Adaptor_Exception
 */
interface Blib_Interface_Data_Adaptor
{
    /**
     * execute a query
     * @param $sql the actual sql query
     * @param $bind as an array
     * @param $cache if true, cache the query in application runtime
     * @return mixed
     */
    function query($sql, $bind = array());

    /**
     * insert data - return last insert id...
     * @param $data as an array
     * @param $tableName the name of the table
     */
    function insert($data, $tableName);

    /**
     * update data
     * must have a condition to do so
     * @param array $data
     * @param str $tableName
     * @param str $condition
     * @return mixed
     */
    function update($data, $tableName, $condition);

    /**
     * delete data
     * must have a condition to do so
     * will always be limited to 1 row only
     * @param str $tableName
     * @param str $condition
     * @return mixed
     */
    function delete($tableName, $condition);


    /**
     * execute a query and fetch one row
     * @param $sql the actual sql query
     * @param $bind as an array
     * @param $cache if true, cache the query in application runtime
     * @return object
     */
    function fetchOne($sql, $bind = array(), $cache = false);


    /**
     * execute a query and fetch all results
     * @param $sql the actual sql query
     * @param $bind as an array
     * @param $cache if true, cache the query in application runtime
     * @return object
     */
    function fetchAll($sql, $bind = array(), $cache = false);

    // returns affected rows count by last operation
    function getRowCount();

}// end Blib_Interface_Data_Adaptor
?>